{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "1d68458b",
   "metadata": {},
   "source": [
    "* 人脸检测\n",
    "人脸比对+人脸搜索"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "63f54b05",
   "metadata": {},
   "source": [
    "## 人脸识别概念和基础"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "96e6c4fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'request_id': '1679676202,fc7b2172-9e16-4520-a59f-ab63e820072f', 'time_used': 260, 'faces': [{'face_token': '0216e5196298cb8869ffd22e3512b4ea', 'face_rectangle': {'top': 322, 'left': 344, 'width': 242, 'height': 242}, 'attributes': {'gender': {'value': 'Female'}, 'age': {'value': 22}, 'smile': {'value': 77.69, 'threshold': 50.0}, 'headpose': {'pitch_angle': -0.033257045, 'roll_angle': 1.2011191, 'yaw_angle': 52.561485}, 'blur': {'blurness': {'value': 57.921, 'threshold': 50.0}, 'motionblur': {'value': 57.921, 'threshold': 50.0}, 'gaussianblur': {'value': 57.921, 'threshold': 50.0}}, 'emotion': {'anger': 0.179, 'disgust': 0.179, 'fear': 1.467, 'happiness': 25.921, 'neutral': 69.886, 'sadness': 1.423, 'surprise': 0.946}, 'facequality': {'value': 0.006, 'threshold': 70.1}, 'beauty': {'male_score': 78.826, 'female_score': 80.757}}}], 'image_id': 'cyHrAAfQDez2D5t/xANX3A==', 'face_num': 1}\n"
     ]
    }
   ],
   "source": [
    "\n",
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "通用物体和场景识别\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('zjy.jpg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "params = {\"api_key\":\"uhFmQ5a93rD1STg5Xk-5SM8mS1V5dGoF\",\n",
    "          \"api_secret\":\"OUNvX4oEjFdVQoW-HTNUndkhrGO6N-lU\",\n",
    "          \"image_base64\":img,\n",
    "          'return_attributes':'gender,age,smiling,headpose,facequality,emotion,blur,beauty'\n",
    "         }\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data=params, headers=headers)\n",
    "if response:\n",
    "    print (response.json())\n",
    "else:\n",
    "    print(response.status_code)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e209f9dd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1b11b499",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
